<?php
    require_once(dirname(dirname(dirname(__FILE__))).'/core.php');

    $minfo = get_mobile_member_info();

    if(!$minfo){
        header('location:/wap/member/login.html');
        exit;
    }

    if(!$_SESSION['member_id']){
        login_member($minfo['member_id']);
    }

    $oinfo = Model()->table('order')->where(array('order_id' => $_GET['order_id'],'buyer_id' => $minfo['member_id']))->Find();

?><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单<?php echo $oinfo['order_sn']?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="full-screen" content="yes"/>
    <meta name="browsermode" content="application"/>
    <!-- QQ强制竖屏 QQ强制全屏 -->
    <meta name="x5-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="x5-page-mode" content="app"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../css/main.css">
	<link rel="stylesheet" type="text/css" href="../../css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/member.css">


    <script src='/wap/js/layer.m/layer.m.js'></script>
    <script type="text/javascript" src="../../js/config.js"></script>
    <script type="text/javascript" src="../../js/zepto.min.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
</head>
<body>
    <header id="header"></header>
    <!--
    <style>
        iframe{
            display: none;
        }
    </style>
    <script>
        layer.open({type : 2,content : '请稍后，正在加载页面'});

        function loaded(){
            layer.closeAll();

            $('iframe').height($(window).height()).show();
        }


    </script>
    <iframe width='100%' height='100%'  frameborder="0"></iframe>

    <script>
         $('iframe')[0].onload = function(){
            loaded();
         }
         $('iframe')[0].src = ('/shop/index.php?act=member_evaluate&op=add&order_id=<?php echo $_GET['order_id']?>&in_mobile=1&width=' + $(window).width())

    </script>
    -->

    <style>
        .box{
            display: block;
            padding: 10px;
        }

        p.tle{
            line-height: 2em;
            font-weight: bold;
            font-size: 1.1em;
            float: left;
            display: block;
            width: 30%;
        }
        p.cnt{
            float: left;
            display: block;
            width: 65%;
            line-height: 2em;
        }
        div.line{
            overflow: hidden;
        }

        select{
            width: 100%;
            vertical-align: middle;
        }

        textarea{
            width: 100%;
            display: block;
            vertical-align: middle;
            margin-top: 1em;
        }

        .submit{
                margin-top: 20px;
                    display: block;
                height: 35px;
                line-height: 35px;
                color: #fff;
                text-align: center;
                width: 100%;
                background: #D9434E;
                margin: 0 auto;
                margin-top: 25px;
        }
        div.line{
            margin-bottom: 10px;
        }
    </style>

    <div class='box'>
        <div class="line">
            <p class="tle">
                评价星级：

            </p>
            <p class="cnt">
                <select name="score" id="">
                    <option value="0">请选择</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                </select>
            </p>

        </div>
        <div class="line">
            <p class="tle">
                评价内容：

            </p>
            <p class="cnt">
                <textarea name="content" id="" cols="30" rows="10"></textarea>
            </p>
        </div>

        <div class="line">
            <a href="javascript:;" class='submit'>提交评价</a>
        </div>
    </div>

    <script>
        $('.submit').click(function(event) {
            var score = $('[name=score]').val();
            if(score == 0){
                layermsg('请选择星级');
                return;
            }
            var content = $('[name=content]').val().trim();
            if(content == ''){
                layermsg('请输入评价内容');
                return;
            }
            var index = layer.open({type : 2});
            $.post('/shop/?act=seccode&op=submit_evalution',{score : score,content : content,order_id : '<?php echo $_GET['order_id']?>'},function(msg){
                layer.close(index);
                if(msg == 'success'){
                    layermsg('评价成功',function(){
                        location.href = '/wap/tmpl/member/order_list.php';
                    })
                }
                else{
                    layermsg('评价失败');
                    history.back();
                }
            });
        });
    </script>
    <div id="footer"></div>




    <script type="text/javascript" src="../../js/template.js"></script>
    <!-- <script type="text/javascript" src="../../js/common.js"></script> -->
    <script type="text/javascript" src="../../js/tmpl/common-top.js"></script>
    <script type="text/javascript" src="../../js/tmpl/footer.js"></script>
</body>
</html>

<script>
        var old_mobile = '<?php echo $minfo['member_mobile']?>';

        $(document).on('change','input[type=file]',function(){
            var file = this.files[0];
            if(!/image\/\w+/.test(file.type)){
                layermsg("请确保文件为图像类型");
                return;
            }
            if(file.size > 1024 * 1024){
                layermsg('请上传小于1M的图片');
                return;
            }
            var reader = new FileReader();
            var bind = $(this).attr('data-bind');
            reader.onload = function(e){
                var re = /^data:base64,/;
                var ret = this.result + '';
                var type = this.type || file.name.match(/\.([^\.]+)$/i)[1]
                if (re.test(ret)) ret = ret.replace(re, 'data:' + type + ';base64,');
                $('input[name="' + bind + '"]').val(ret);
                console.log(this.result)
                if($('img[data-bind="' + bind + '"]').length){
                    $('img[data-bind="' + bind + '"]').attr('src',this.result).show();
                }
            }
            console.log(this.files[0]);
            reader.readAsDataURL(this.files[0]);
        });

        $('.add_address').click(function(){
            var mobile = $('[name="member_mobile"]').val().trim();
            if(mobile != ''){
                if(!/^1[345789][0-9]{9}$/.test(mobile)){
                    layermsg('请输入正确的手机号码');
                    return false;
                }
            }
            var idcard = $('[name="idcard"]').val().trim();

            if(!/^[\dx]{15,18}$/.test(idcard)){
                layermsg('请输入正确的身份证号');
                return false;
            }

            if(mobile != ''){
                if(old_mobile != mobile && $('[name="mobile_code"]').val() == ''){
                    $.get('/shop/index.php?act=seccode&op=send_message',{check_captcha:false,mobile:mobile},function(msg){
                        if(msg == 0x01 << 1){
                            layermsg('手机号码不正确');
                            return false;
                        }
                        if(msg == 0x01 << 2){
                            layermsg('该手机已被绑定');
                            return false;

                        }
                        if(msg == 0x01 << 3){
                            layermsg('短信发送失败');
                        }

                        layermsg('您的手机号码已变更<br>请输入手机验证码');
                        $('#captcha').show();
                    });

                    return false;
                }
            }


            $('form').submit();
        });
    </script>